﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Entity;
using System.Runtime.Serialization;
namespace Data.Sql　//使用SQL实现查询
{
    public class Res_ItemRepository : EEE114RepositoryBase, IRepository<Res_Item>
    {
        #region IRepository<Res_Item> 成员

        public IQueryable<Res_Item> GetModel()
        {
            return base.GetEntities<Res_Item>();
        }

        public IQueryable<Res_Item> GetDetailModel()
        {
            var linq = from data1 in DB.GetTable<View_Res_Item_CategoryProperty_R>()
                       select new Res_Item_Ext
                      {
                          ID = data1.ID,
                          Name = data1.Name,
                          PackageTime = data1.PackageTime,
                          Picture = data1.Picture,
                          Recommend = data1.Recommend,
                          CategoryID = data1.CategoryID,
                          VID = data1.ValueID ?? 1,
                          ApplicableObject = data1.ApplicableObject,
                          BigPicture = data1.BigPicture,
                          ClassHour = data1.ClassHour,
                          ClassTarget = data1.ClassTarget,
                          Clicks = data1.Clicks,
                          Collects = data1.Collects,
                          Feature = data1.Feature,
                          FreeRes = data1.FreeRes,
                          Gift = data1.Gift,
                          GiftInfo = data1.GiftInfo,
                          Holder = data1.Holder,
                          Info = data1.Info,
                          IsAgentPrice = data1.IsAgentPrice,
                          ItemType = data1.ItemType,
                          Packager = data1.Packager,
                          PayType = data1.PayType,
                          ResourceCount = data1.ResourceCount,
                          SaleRadix = data1.SaleRadix,
                          Sales = data1.Sales,
                          Scores = data1.Scores,
                          SmallPicture = data1.SmallPicture,
                          Status = data1.Status,
                          UpdateTime = data1.UpdateTime,
                          Uploader = data1.Uploader,
                      };
            return linq.Cast<Res_Item>();
        }

        public void Insert(Res_Item entity)
        {
            base.InsertEntity(entity);
        }

        public void Delete(Res_Item entity)
        {
            base.DeleteEntity(entity);
        }

        public void Update(Res_Item entity)
        {
            base.UpdateEntity(entity);
        }

        #endregion

        #region IRepository<Res_Item> 成员


        public void Update(IList<Res_Item> list)
        {
            throw new NotImplementedException();
        }

        public void Insert(IList<Res_Item> list)
        {
            throw new NotImplementedException();
        }

        public Res_Item InsertGetIDENTITY(Res_Item entity)
        {
            throw new NotImplementedException();
        }

        public void Delete(IList<Res_Item> list)
        {
            throw new NotImplementedException();
        }

        public Res_Item Find(params object[] keyValues)
        {
            throw new NotImplementedException();
        }

        #endregion
    }
}